<!DOCTYPE html PUBLIC>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>修改首页活动详情</title>
    <link href="$!webPath/css/template.css" rel="stylesheet" type="text/css"/>
    <link href="$!webPath/css/jquery-ui-1.8.22.custom.css" type="text/css"
          rel="stylesheet">
    <script src="$!webPath/js/jquery-1.6.2.js"></script>
    <script src="$!webPath/js/jquery-ui-1.8.21.js"></script>
    <script src="$!webPath/js/jquery.min.js"></script>
    <script src="$!webPath/js/jquery.form1.js"></script>

    <style type="text/css">
        label.error {
            color: #F00;
            margin-left: 3px;
        }

        input.error {
            border: 2px solid #F00;
        }
    </style>
</head>
<body>

<div class="header_nav">
    <iframe name="content_frame" src="$!webPath/admin/nav" marginwidth=0 marginheight=0  frameborder=0 width=100% height=80/></iframe>
    <div class="cont_right"><a href="$!webPath/login">注销</a></div>
</div>
<div class="cont">
    <h3 class="seth">编辑</h3>
    <div class="nav_list">
        <ul id="ul_table">
            <li><a href="$!webPath/admin/introduction/introduction_list?size=10&page=0"><b>首页介绍列表</b></a></li>
            <li><a href="javascript:void(0);" class="this"><b>编辑</b></a></li>
        </ul>
    </div>
    <div class="adddetail">
        <form method="post" name="theForm" id="theForm"  enctype="multipart/form-data">
  
			<div class="edit">
            <div class="setcont editul">
                
                <ul class="set1">
                    <li class="setcont_bg">活动标题</li>
                    <li>
                        <input name="name" id="active_name" type="text" value="$!homeIntroductionEntity.name" size="30">
                    </li>
                </ul>
                <ul class="set1">
                    <li class="setcont_bg">活动副标题</li>
                    <li>
                        <span class="webname">
                          <input name="shortTitle" id="active_desc" type="text" value="$!homeIntroductionEntity.shortTitle" size="30">
                        </span>
                    </li>
                </ul>
                <ul class="set1">
                    <li class="setcont_bg">首页序列</li>
                    <li>
                        <span class="webname">
                          <input name="sequence" id="sequence" type="text" value="$!homeIntroductionEntity.sequence" size="30">
                        </span>
                    </li>
                </ul>
                <ul class="set1">
                    <li class="setcont_bg"></li>
                    <li>
                        <!--商品图片上传 -->
                        <div class="tab_body" style="width: 500px">
                            <ul class="tabbody_ul">
                                <li class="this">图</li>
                            </ul>
                            <div class="tabbodys" style="width: 498px;">
                                <div class="tab_body_b" style="width: 500px;"></div>
                                <div class="tab_body_a" style="width: 500px;">
                                    <div class="upload_pictures">
                                        <div class="upload_pictures_top">
                                            <div class="upload_pictures_top_img">

                                                <img id="showImg" src="$!webPath/$!homeIntroductionEntity.picPath" />

                                            </div>
                                        </div>
                                        <div class="upload_pictures_bottom">
                                            <ul>
                                                <input type="hidden" name="id" value="$!homeIntroductionEntity.id">
                                                <!--<input type="hidden" name="pictureName" id="pictureName"/>-->
                                                <input type="file" id="goodsPhoto" name="photo" style="opacity:1;position: static;" accept="image/jpg,image/jpeg,image/png">
                                            </ul>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>

    
        </form>
        <div class="submit">
            <span class="pad120">
            <input name="save" type="button" value="提交" id="btn_saveForm">
            </span>
        </div>
    </div>
</div>
<script>
        $('#goodsPhoto').change(function(){
            var $file = $(this);
            var fileObj = $file[0];
            var windowURL = window.URL || window.webkitURL;
            var dataURL;
            var $img = $("#showImg");

            if (fileObj && fileObj.files && fileObj.files[0]) {
                dataURL = windowURL.createObjectURL(fileObj.files[0]);
                $img.attr('src', dataURL);
            } else {
                dataURL = $file.val();
                var imgObj = document.getElementById("preview");
                // 两个坑:
                // 1、在设置filter属性时，元素必须已经存在在DOM树中，动态创建的Node，也需要在设置属性前加入到DOM中，先设置属性在加入，无效；
                // 2、src属性需要像下面的方式添加，上面的两种方式添加，无效；
                imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;

            }
        })
        $('#btn_saveForm').click(function(){
            var active_name=$('#active_name').val();
            var active_desc=$('#active_desc').val();
            var sequence=$('#sequence').val();
            var picPath=$('#goodsPhoto').val();
            if(active_name==''||active_desc==''||sequence==''){
                alert('活动名称，活动短标题，首页序列不能为空');
                return false;
            }
            $("#theForm").ajaxSubmit({
                url : "$!webPath/admin/add_introduction",
                type : "post",
                //data:{id:'$!homeIntroductionEntity.id',name:active_name,shortTitle:active_desc,sequence:sequence,picPath:picPath},
                success : function(data) {
                    window.location.href = "$!webPath/admin/introduction/introduction_list?size=10&page=0";
                },
                error : function(data) {
                    alert('失败');
                }
            });
        })

</script>
</body>
</html>
